<?php

namespace app\front\controller;


use think\Controller;

class Base extends Controller
{
    protected $middleware = ['Auth'];



    /**
     * 返回正确的信息
     * @param $data
     * @param int $code
     * @param string $msg
     * @return false|string
     */
    public function returnSuccess($data, $code = 10000, $msg = '操作成功')
    {
        return json_encode([
            'status' => 200,
            'code'   => $code,
            'msg'    => $msg,
            'data'   => $data
        ]);
    }

    /**
     * 返回错误的信息
     * @param null $data
     * @param int $code
     * @param string $msg
     * @return false|string
     */
    public function returnError($data = null, $code = 20000, $msg = '操作失败')
    {
        return json_encode([
            'status' => 500,
            'code'   => $code,
            'msg'    => $msg,
            'data'   => $data
        ]);
    }
}